<?php
namespace app\common\validate;

use think\Validate;

class MerchantAuth extends Validate
{
    protected $rule = [
        'store_name' => 'require|max:20',
        'store_phone' => 'require|regex: /^1[3-9]\d{9}$/',
        'store_logo' => 'require',
        'province' => 'require',
        'city' => 'require',
        'district' => 'require',
        'address' => 'require|max:50',
        'business_license' => 'require',
        'id_card_front' => 'require',
        'id_card_back' => 'require',
    ];
    
    protected $message = [
        'store_name.require' => '店铺名称不能为空',
        'store_name.max' => '店铺名称不能超过20个字符',
        'store_logo' => '请上传店铺头像',
        'store_phone.require' => '店铺电话不能为空',
        'store_phone.regex' => '请输入有效的手机号码',
        'province.require' => '请选择省份',
        'city.require' => '请选择城市',
        'district.require' => '请选择区/县',
        'address.require' => '详细地址不能为空',
        'address.max' => '详细地址不能超过50个字符',
        'business_license.require' => '请上传营业执照',
        // 'business_license.filePath' => '营业执照路径格式不正确',
        'id_card_front.require' => '请上传身份证正面照',
//        'id_card_front.filePath' => '身份证正面照路径格式不正确',
        'id_card_back.require' => '请上传身份证反面照',
//        'id_card_back.filePath' => '身份证反面照路径格式不正确',
    ];
    
    // 自定义文件路径验证规则
    // protected function checkFilePath($value, $rule, $data = [])
    // {
    //     // 匹配完整URL格式，允许http或https开头，支持正斜杠、反斜杠、下划线和点号
    //     return preg_match('/^https?:\/\/[^\s\/]+(\.[^\s\/]+)*\/uploads\/[a-zA-Z0-9\/\\_\.]+$/', $value);
    // }
}